package com.igoal.dao;

import java.util.Date;
import java.util.List;

import com.igoal.entity.UserGoal;
import com.igoal.entity.UserGoalPk;

/** 
 * DAO for {@link UserGoal} entity
 * @author Tri
 * @since 6/19/2010
 */
public interface UserGoalDAO extends GenericDao<UserGoal, UserGoalPk> {
	/**
	 * Get all goal of an specified user
	 * @param userId
	 * @return list of {@link UserGoal}
	 */
	List<UserGoal> findByUserId(Long userId);
	
	/**
	 * Get goal of an specified user
	 * @param userId 
	 * @param goalId
	 * @return {@link UserGoal}
	 */
	UserGoal findByPK(Long userId, Long goalId);
	
	/**
	 * Check exists composite key
	 * @param userId user
	 * @param goalId goal
	 * @return true if exists
	 */
	boolean exists(Long userId, Long goalId);
	
	/**
	 * Get goals of user that completed or doing
	 * @param userId
	 * @param completed
	 * @return
	 */
	List<UserGoal> getUserGoal(Long userId, boolean completed);
	
	/**
	 * Get users have same activity with the specified goal
	 * @param goalId
	 * @param completed doing or completed goal
	 * @param any any activity (done check status)
	 * @return list of {@link UserGoal}
	 */
	List<UserGoal> getUserGoal(Long goalId, boolean completed, boolean any, int numberOfUser);
	
	int countDoUsers(Long goalId);

	int countDoingUsers(Long goalId);
	
	int countDoneUsers(Long goalId);
	
	List<UserGoal> getRandomUserDoGoal(Long goalId);
	
	List<UserGoal> getUsersDoGoal(Long goalId, int pageNumber);
	
	List<UserGoal> getCreatedUserGoalInToday(Long userId);
	
	List<UserGoal> getCreatedUserGoalInDate(Long userId, Date date);
	
	int countCreatedUserGoalInToday(Long userId);
	
	int countCreatedUserGoalInDate(Long userId, Date date);
	
	int countGoals(Long userId, boolean finished);
}
